<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	String contextPath = request.getContextPath();
%>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="pragma" content="no-cache">  
<meta http-equiv="cache-control" content="no-cache">  
<meta http-equiv="expires" content="0"> 

<link rel="stylesheet" type="text/css" href="<%=contextPath %>/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<%=contextPath %>/themes/icon.css">
<script type="text/javascript" src="<%=contextPath %>/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=contextPath %>/js/base.js"></script>
<script>contextPath = "<%=contextPath %>";</script>

<script language="javascript">
$(function() {
	initDatePicker("query_startCreateTime");
   initDatePicker("query_endCreateTime");
   
   initButton("create-contract", function() {
	   openAddForm();
	});
   
	initButton("modify-contract", function() {
		openModifyForm();
	});
	
	initButton("query-contract", function() {
		$("#queryForm").attr("action", "contract_listAction.action");
		$("#queryForm").submit();
	});
	
	initButton("query-reset", function() {
		$("#query_contractName").val("");
		$("#query_contractCode").val("");
		$("#query_startCreateTime").datebox('setValue', '');
		$("#query_endCreateTime").datebox('setValue', '');
		$("#query_projectId").val("");
		$("#query_projectName").val("");
	});
	
	
	initButton("delete-contract", function() {
		$("#queryForm").attr("action", "contract_deleteContractAction.action");
		deleteRecord('queryForm', 'dataTable', 'contractId');
	});	
	
	
	
	$('#dataTable').datagrid(
			{
				url: "contract_dataGridAction.action?"+buildCondition(),
				width: '100%',
				height: 'auto',
				striped: true,
				fitColumns: false,
				pagination:true,
				columns:[[
					{field:'contractId',checkbox:true},
					{field:'contractCode',title:'合同编号',width:120,
						formatter:function(value,rowData,rowIndex){
							return '<a href="#" onclick="openViewForm(\''+rowData['contractId']+'\')">' + value + '</a>';
						}},
					{field:'contractName',title:'合同名称',width:120},
					{field:'projectName',title:'所属项目',width:120},
					{field:'amount',title:'合同金额',width:100,
						formatter:function(value){
							return moneyForamt(value);	
						}},
					{field:'fukuan',title:'付款情况',width:80,
						formatter:function(value,rowData){
							var queryContractName = encodeURIComponent(rowData['contractName']);
							return '<a href="#" onclick="$(window.parent)[0].openTab(\'payment_listAction.action?query_contractName='+queryContractName+'&query_contractId='+rowData['contractId']+'\', \'付款明细\', \'new\')">付款</a>';
						}},
					{field:'createUserName',title:'创建人',width:80},
					{field:'createTime',title:'创建日期',width:100,
						formatter:function(value,rec){
							if (value == null || value == '') {
								return '';
							} else {
								return new Date(Date.parse(value.replace(/-/g, "/"))).format("yyyy-MM-dd");	
							}							
						}},
					{field:'updateUserName',title:'更新者',width:100},
					{field:'updateTime',title:'更新时间',width:140},
					{field:'remark',title:'备注'}
				]]
			});
});


function buildCondition() {

	return "query_contractName="+
		encodeURIComponent($("#query_contractName").val())+
			"&query_contractCode="+
		encodeURIComponent($("#query_contractCode").val())+
			"&query_projectId="+
		$("#query_projectId").val()+
			"&query_startCreateTime="+
		$("#query_startCreateTime").datebox('getValue')+
			"&query_endCreateTime="+
		$("#query_endCreateTime").datebox('getValue');
}
   
</script>
</head>

<body>

 
<form id="queryForm" action="contract_listAction.action" method="post">
<div id="queryDiv" class="easyui-accordion" border="false" style="width: 400px;">
	<div title="查询" iconCls="icon-search" style="overflow:auto;padding:10px;">
	<table>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">合同名称:</label>
				<s:textfield name="query_contractName" theme="simple"  />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">合同编号:</label>
				<s:textfield name="query_contractCode" theme="simple"  />
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">所属项目:</label>
				<s:hidden name="query_projectId" />
				<s:textfield name="query_projectName" theme="simple" readonly="true" onclick="popUpWin('query_projectId', 'query_projectName');"  />	
			</td>
		</tr>
		<tr>
			<td>
				<label style="float: left; margin-right: 5px;">创建日期:</label>
				<s:textfield name="query_startCreateTime" theme="simple" />
				~
				<s:textfield name="query_endCreateTime" theme="simple" />
			</td>
		</tr>
		<tr>
			<td style="vertical-align: top;" colspan="2">
				<a href="javascript:void(0)" id="query-contract" class="easyui-linkbutton" iconCls="icon-search">查询</a>
				<a href="javascript:void(0)" id="query-reset" class="easyui-linkbutton" iconCls="icon-back">重置</a>
			</td>
		</tr>
	</table>
	</div>	
</div>
	
<hr/>

<div style="width: 100%;">
	<table id="dataTable" title='项目列表'></table>
</div>
<div style="margin-top: 5px;">
	<a href="javascript:void(0)" id="create-contract" class="easyui-linkbutton" iconCls="icon-add">新建</a>
	<a href="javascript:void(0)" id="modify-contract" class="easyui-linkbutton" iconCls="icon-edit">修改</a>
	<a href="javascript:void(0)" id="delete-contract" class="easyui-linkbutton" iconCls="icon-cancel">删除</a>
</div>

<input type="hidden" name="deleteId" id="deleteId" />


<s:include value="contract_new.jsp"></s:include>
<s:include value="../include/project_popup.jsp"></s:include>

</form>
</body>
</html>